/**
 * desc：常用工具函数
 */
import {Portal, Toast} from '@ant-design/react-native';

let key;

export default class ToastUtils {
  static showInfo(content) {
    if (content) {
      Toast.info(content, 1, null, false);
    }
  }
  static showFailInfo(content) {
    Toast.offline(content, 1, null, false);
  }

  static showSuccessInfo(content) {
    Toast.success(content, 1, null, false);
  }

  static showLoading(content) {
    key = Toast.loading(content, 0, null, true);
  }

  static hide() {
    if (key) {
      Portal.remove(key);
    }
  }

  //是否正在loading
  static isShowLoading() {
    return !!key;
  }
}
